package com.yayan.xh.service;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.yayan.xh.bean.EnterBean;
import com.yayan.xh.dao.EnterDao;
import com.yayan.xh.dao.IEnterDao;

@Service
public class EnterService implements IEnterService {
	
	private IEnterDao enterDao;
	
	public EnterService() {
		enterDao = new EnterDao();
	}

	@Override
	public List<Map<String, Object>> getFrontEnter(Map<String, String> map) {
		List<Map<String, Object>> result = null;
		try {
			if(null != map.get("shopId") && null != map.get("userId")
					&& !"0".equalsIgnoreCase(map.get("shopId")) && !"0".equalsIgnoreCase(map.get("userId"))) {
				result = enterDao.getEnter(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}
	
	@Override
	public List<Map<String, Object>> getFrontJoin(Map<String, String> map) {
		List<Map<String, Object>> result = null;
		try {
			if(null != map.get("shopId") && null != map.get("userId")
					&& !"0".equalsIgnoreCase(map.get("shopId")) && !"0".equalsIgnoreCase(map.get("userId"))) {
				result = enterDao.getJoin(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}
	

	@Override
	public boolean signCode(Map<String, String> map) {
		boolean f = false;
		try {
			if(null != map.get("shopId") && null != map.get("userId") && null != map.get("matchId")
					&& !"0".equalsIgnoreCase(map.get("shopId")) && !"0".equalsIgnoreCase(map.get("userId"))
					&& !"0".equalsIgnoreCase(map.get("matchId"))) {
				f = enterDao.signCode(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return f;
	}

	@Override
	public List<EnterBean> getBackEnter(Map<String, String> map) {
		List<EnterBean> list = null;
		try {
			if(null != map.get("shopId") && null != map.get("matchId")
					&& !"0".equalsIgnoreCase(map.get("shopId")) && !"0".equalsIgnoreCase(map.get("matchId"))) {
				list = enterDao.getEnterBack(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}

	@Override
	public List<EnterBean> getLuckDraw(Map<String, String> map) {
		List<EnterBean> list = null;
		try {
			if(null != map.get("shopId") && null != map.get("matchId")
					&& !"0".equalsIgnoreCase(map.get("shopId")) && !"0".equalsIgnoreCase(map.get("matchId"))) {
				list = enterDao.getLuckDraw(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}

	@Override
	public List<EnterBean> getLuckBoys(Map<String, String> map) {
		List<EnterBean> list = null;
		try {
			if(null != map.get("shopId") && null != map.get("matchId")
					&& !"0".equalsIgnoreCase(map.get("shopId")) && !"0".equalsIgnoreCase(map.get("matchId"))) {
				list = enterDao.getLuckBoys(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}

	@Override
	public boolean updateLuckBoy(Map<String, String> map) {
		boolean f = false;
		try {
			if(null != map.get("shopId") && null != map.get("eId")
					&& !"0".equalsIgnoreCase(map.get("shopId")) && !"0".equalsIgnoreCase(map.get("eId"))) {
				f = enterDao.updateLuckBoy(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return f;
	}

	@Override
	public EnterBean getFrontEnterById(Map<String, String> map) {
		EnterBean result = null;
		try {
			if(null != map.get("shopId") && null != map.get("userId") && null != map.get("matchId")
					&& !"0".equalsIgnoreCase(map.get("shopId")) && !"0".equalsIgnoreCase(map.get("userId"))
					&& !"0".equalsIgnoreCase(map.get("matchId"))) {
				result = enterDao.getEnterById(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

}
